//
// Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
//
// GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
//  Author: Shawn.Tan
//  Date : 2025.10.28
//
//  History : Initial Version 2025.10.28
//
//
#include "VmConstraint.h"

#include <sstream>

#include "Constraint.h"
#include "Log.h"

using namespace std;

/*!
  \file VmConstraint.cc
  \brief Code managing VmConstraint objects.
*/

namespace Green {

  string VmConstraint::ToString() const
  {
    stringstream out_str;

    out_str << "VmConstraint " << EVmConstraintType_to_string(Type()) << " requiring " << Requiring() << ": " << mpConstraint->ToSimpleString();

    return out_str.str();
  }

  void VmInConstraint::ApplyOn(ConstraintSet& rConstrSet) const
  {
    rConstrSet.ApplyLargeConstraintSet(*mpConstraint);
  }

  bool VmInConstraint::Allows(uint64 value) const
  {
    return mpConstraint->ContainsValue(value);
  }

  void VmNotInConstraint::ApplyOn(ConstraintSet& rConstrSet) const
  {
    rConstrSet.SubConstraintSet(*mpConstraint);
  }

  bool VmNotInConstraint::Allows(uint64 value) const
  {
    return not mpConstraint->ContainsValue(value);
  }

}
